home *** CD-ROM | disk | FTP | other *** search
- /*
- File: LineOps.h
-
- Contains: Geometric operations on lines in 2-space.
-
- Owned by: Jens Alfke
- IntersectLines by Ken Turkowski, from Apple Technical Memorandum KT14.
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Theory of Operation:
-
- Endpoints of lines or ranges need not be given in any particular order.
-
- Ranges include both endpoints, unline rectangles which don't include right and bottom.
- (This is necessary to make segments that share an endpoint intersect, and to make e.g.
- the horizontal range of a vertical line be non-empty.)
-
- */
-
-
- #ifndef _LINEOPS_
- #define _LINEOPS_
-
- #ifndef _ODTYPES_
- #include "ODTypes.h"
- #endif
-
-
- enum{
- kIntersection, // Segments intersect
- kOutsideIntersection, // Lines intersect, but past ends of segments
- kNoIntersection // Lines are parallel or degenerate
- };
- typedef short IntersectionStatus;
-
-
- const ODCoordinate kFixedEpsilon = 7; // This is about 0.0001 pixels
-
-
- extern "C" {
-
-
- inline ODCoordinate Min( ODCoordinate a, ODCoordinate b ) {return a<b ?a :b;}
- inline ODCoordinate Max( ODCoordinate a, ODCoordinate b ) {return a>b ?a :b;}
-
- inline ODCoordinate Abs( ODCoordinate n ) {return n>=0 ?n :-n;}
-
- Boolean WithinEpsilon( ODCoordinate a, ODCoordinate b );
-
- ODCoordinate Distance( const ODPoint &p0, const ODPoint &p1 );
-
- void GetLineShift( ODPoint p0, ODPoint p1, ODCoordinate dist,
- ODPoint &delta );
-
- IntersectionStatus IntersectLines( const ODPoint &p0, const ODPoint &p1,
- const ODPoint &q0, const ODPoint &q1,
- ODPoint *sect );
-
- Boolean IntersectSegments( const ODPoint &p0, const ODPoint &p1,
- const ODPoint &q0, const ODPoint &q1,
- ODPoint *sect );
-
- ODCoordinate GetLineXAtY( const ODPoint &p0, const ODPoint &p1,
- ODCoordinate y );
-
- Fract GetIntersectionT( const ODPoint &p0, const ODPoint &p1,
- const ODPoint § );
-
- Boolean InRange( ODCoordinate n, ODCoordinate r0, ODCoordinate r1 );
-
- Boolean RangesDisjoint( ODCoordinate a0, ODCoordinate a1,
- ODCoordinate b0, ODCoordinate b1 );
-
- }
-
- #endif /*_LINEOPS_*/